package com.un.ebs.workflow.event;

import com.un.ebs.core.util.SpringContextUtil;
import com.un.ebs.inventory.enums.InventoryTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.context.ApplicationEvent;

@SuppressWarnings("ALL")
@EqualsAndHashCode(callSuper = false)
@Data
public class WorkflowInstancePushEvent extends ApplicationEvent {

    /**
     * 节点实例
     */
    private String nodeInstanceId;

    /**
     * 流程实例
     */
    private String workflowInstanceId;

    /**
     * 业务类别
     */
    private InventoryTypeEnum inventoryTypeEnum;

    /**
     * 业务ID
     */
    private String noteId;

    /**
     * 流程实例是否关闭
     */
    private boolean isClose = false;

    /**
     * 流程节点是否通过
     */
    private boolean isPass = false;

    public WorkflowInstancePushEvent(Object source,String workflowInstanceId, String nodeInstanceId, String noteId, InventoryTypeEnum inventoryType, boolean isClose,boolean isPass) {
        super(source);
        this.nodeInstanceId = nodeInstanceId;
        this.workflowInstanceId=workflowInstanceId;
        this.inventoryTypeEnum = inventoryType;
        this.noteId = noteId;
        this.isClose = isClose;
        this.isPass=isPass;
    }

    public static void publishEvent(Object source,String workflowInstanceId, String nodeInstanceId, String noteId, InventoryTypeEnum inventoryType, boolean isClose,boolean isPass) {
        WorkflowInstancePushEvent event = new WorkflowInstancePushEvent(source,workflowInstanceId, nodeInstanceId, noteId, inventoryType, isClose,isPass);
        SpringContextUtil.getApplicationContext().publishEvent(event);
    }
}
